use crate::core::error::ParrotError;
use crate::core::operation::{cmd, copy_entries_into, download, git, unzip};
use snafu::Snafu;

#[derive(Debug, Snafu)]
#[snafu(visibility(pub(crate)))]
pub enum OperationError {
    #[snafu(display("Failed to run command: {source}"))]
    Cmd { source: cmd::Error },

    #[snafu(display("Failed to copy entries into directory: {source}"))]
    CopyEntriesInto { source: copy_entries_into::Error },

    #[snafu(display("Failed to download things: {source}"))]
    Download { source: download::Error },

    #[snafu(display("Failed to clone git repository: {source}"))]
    Git { source: git::Error },

    #[snafu(display("Failed to unzip file: {source}"))]
    UnZip { source: unzip::Error },
}

impl From<OperationError> for ParrotError {
    fn from(value: OperationError) -> Self {
        ParrotError::Operation { source: value }
    }
}
